

import UIKit

class MeViewController: UIViewController
{
    @IBOutlet weak var UserName: UILabel!
    @IBOutlet weak var UserSex: UILabel!
    @IBOutlet weak var UserRole: UILabel!
    @IBOutlet weak var Collectnum: UILabel!
    @IBOutlet weak var Afridnum: UILabel!
    @IBAction func Attention(_ sender: UIButton)
    {
        let alarm = UIAlertController(title: nil, message: "关注功能尚未上线", preferredStyle: .alert)
        alarm.addAction(UIAlertAction(title: "好", style: .default, handler: nil))
        self.present(alarm, animated: true, completion: nil)
    }
    @IBAction func shoucang(_ sender: UIButton)
    {
        let alarm = UIAlertController(title: nil, message: "收藏功能尚未上线", preferredStyle: .alert)
        alarm.addAction(UIAlertAction(title: "好", style: .default, handler: nil))
        self.present(alarm, animated: true, completion: nil)
    }
    @IBAction func logout(_ sender: UIBarButtonItem)
    {
        let device=UIDevice.current.model
        let alarm:UIAlertController!
        if(device == "iPhone")
        {
            alarm = UIAlertController(title: nil, message: "是否注销", preferredStyle: .actionSheet)
            
        }
        else
        {
            alarm = UIAlertController(title: nil, message: "是否注销", preferredStyle: .alert)
        }
        alarm.addAction(UIAlertAction(title: "取消", style: .cancel, handler: nil))
        alarm.addAction(UIAlertAction(title: "注销", style: .destructive, handler: {
            (UIAlertAction) in
            let parameters = ["SessionID":networktool.loginReturnModel!.sessionid!]
            networktool.shared.account_logout(parameters as NSDictionary)
            self.dismiss(animated: true, completion: {
                NotificationCenter.default.post(name:Notification.Name(rawValue: "accountlogout"),object:nil,userInfo:nil )
            })
        }))
        self.present(alarm, animated: true, completion: nil)
        
    }
    override func viewDidLoad()
    {
        super.viewDidLoad()
        
        UserName.text = networktool.loginReturnModel?.realname
        if (networktool.loginReturnModel?.sex == "男" || networktool.loginReturnModel?.sex == "女" )
        {
            UserSex.text  = networktool.loginReturnModel?.sex
        }else
        {
            UserSex.text  = "Unknow"
        }
        if (networktool.loginReturnModel?.rolename == "老师" || networktool.loginReturnModel?.rolename == "学生" )
        {
            UserRole.text  = networktool.loginReturnModel?.rolename
        }else
        {
            UserRole.text  = "Unknow"
        }
        
        
        
        // Do any additional setup after loading the view.
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
